<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<!-- 开发环境版本，包含了有帮助的命令行警告 -->
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<title></title>
	
</head>
<body>
	<div id="app">
		<comp @compmethodmsg="alertMsg"></comp>
	</div>

	<template id="tmp">
		<button @click="handlerMethod">点我</button>
	</template>
	
	<script type="text/javascript">
		let comp=Vue.extend({
			template: "#tmp",
			methods:{
				handlerMethod(){
					//第一个参数表示要调用的方法
					//第二个参数表示要传递的参数
					this.$emit("compmethodmsg","调用")
				}
			}
		})
		let app=new Vue({
			el:"#app",
			data:{},
			methods:{
				alertMsg(msg){
					alert(msg);
				}
			},
			components:{
				comp
			}
		})
	</script>
</body>
</html>